from duetopia.register.models import *

test_series = """<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	 xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:data="http://sweet.jpl.nasa.gov/1.1/data.owl#"
         xmlns:time="http://sweet.jpl.nasa.gov/1.1/time.owl#">

<data:DataProduct rdf:about="http://www.example.com/">
  <dc:title>Test Data Series</dc:title>
  <time:Start>1970-01-01</time:Start>
  <time:End>1980-01-01</time:End>
</data:DataProduct>

<data:Dataset rdf:about="http://www.example.com/dataset/">
  <data:DataProduct rdf:resource="http://www.example.com/" />
  <dc:title>Test Data Set</dc:title>
  <time:Start>1970-01-01</time:Start>
  <time:End>1975-01-01</time:End>
</data:Dataset>

</rdf:RDF>
"""
import RDF
storage = RDF.Storage(storage_name="memory", name="memory", options_string="")
model = RDF.Model(storage)
parser = RDF.Parser()
parser.parse_string_into_model(model, test_series, "http://www.example.com/")
print DataSet.objects.rdf_get_or_create(model, RDF.Uri("http://www.example.com/dataset/"), update=True)

